/*
 *  Copyright (C) 2011 ryansullivan
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package client;

import java.io.DataOutputStream;
import java.net.Socket;

/**
 * This is the client object that will handle all communication
 * between the client and server.
 * @author Ryan Sullivan
 */
public class CommandClient {
    
    private String hostname = new String();
    private int socketNum = 6789;
    private ClientServerThread server;

    public CommandClient(String newHostname) throws Exception{
        hostname = newHostname;
        //server = new ClientServerThread(6791);
        sendToServer("0:Connected");
    }

    public void sendToServer(String DataToSend) throws Exception{
        /* Setup */
        Socket serverSocket = new Socket(hostname, socketNum);
        DataOutputStream outToServer = new DataOutputStream(serverSocket.getOutputStream());
        /* Send Data */
        outToServer.writeBytes(DataToSend + '\n');
        /* Close Socket */
        outToServer.close();
    }
}